package com.ctbri.arrays;

import java.util.Arrays;
import java.util.Comparator;
import java.util.Random;

public class Ex24 {
	public static void main(String[] args) {
		Random random = new Random();
		Test[] a = new Test[10];
		for (int i = 0; i < a.length; i++)
			a[i] = new Test(random.nextInt(1000));
		Comparator<Test> c = new Comparator<Test>() {

			@Override
			public int compare(Test o1, Test o2) {
				return (o1.value < o2.value ? -1 : (o1.value == o2.value ? 0 : 1));
			}

		};
		Test t = a[8];
		Arrays.sort(a, c);
		int index = Arrays.binarySearch(a, t, c);
		System.out.println(index);
	}
}
